/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Libros;

import Tablas.Libros;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

/**
 *
 * @author carlosenriquez
 */
public class Delete {
    public static void main(String args[]){
        Session session = null;
        try{
            Configuration configuration=new Configuration();
            SessionFactory sessionFactory=configuration.configure().buildSessionFactory();
            session=sessionFactory.openSession();
            Transaction transaction=session.beginTransaction();
//            Short uno=1;
            Libros lib=new Libros();
            lib.setIdLibros(1);
            session.delete(lib);
            transaction.commit();
            System.out.println("Hecho!");
        }catch(Exception e){ 
            System.out.println(e.getMessage());
        }
        finally{
            session.flush();
            session.close();
        }
    }
    
}
